package com.health.work.utils;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap.CompressFormat;
import android.util.Log;

public class BitmapBase64 {

	public static String getBitmapStringBase64(Bitmap bitmap) {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		bitmap.compress(CompressFormat.PNG, 100, baos);
		byte[] bytes = baos.toByteArray();
		return Base64.encodeBytes(bytes);
	}
	
	public static Bitmap getBitmap(String iconBase64) {
		byte[] bitmapArray = null;
		try {
			bitmapArray = Base64.decode(iconBase64);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.length);
	}
}
